Weighing = Widget.extend({
	ctor:function(){
		this._super();
		this.init();
		this.inputInto();
		this.setTag(TAG_WEIGHING_ALL);
	},
	init:function(){
		this.body = new Button(this, 10, TAG_WEIGHING, "#WeighingBottle/c2.png", this.callback,this);
		this.body.setScale(0.65);
		var cup=new Button(this.body,10,TAG_CUP,"#WeighingBottle/clplid.png",this.callback,this);
		cup.setPosition(cc.p(this.body.width*0.5, this.body.height*0.95));
		//拿纸
		var right1=new Button(this.body,0,TAG_RIGHT_1,"#brush/right1.png",this.callback,this);
		right1.setPosition(cc.p(this.body.width*2.85, this.body.height*0.3));
		right1.setScale(1.5);
		right1.setVisible(false);
		var paper=new Button(right1,10,TAG_PAPER,"#paper1.png",this.callback,this);
		paper.setPosition(cc.p(this.body.width*0.28, this.body.height*0.85));
		var right2=new Button(right1,10,TAG_RIGHT_2,"#brush/right3.png",this.callback,this);
		right2.setPosition(cc.p(right1.width*0.5,right1.height*0.5));
		//拿称量瓶
		var right_1=new Button(this,10,TAG_RIGHT11,"#WeighingBottle/right_1.png",this.callback,this);
		right_1.setPosition(this.body.width*4.2,-this.body.height*0.35);
		right_1.setScale(0.65);
		right_1.setVisible(false);
		var right_2=new Button(right_1,10,TAG_RIGHT12,"#WeighingBottle/right_2.png",this.callback,this);
		right_2.setPosition(cc.p(right_1.width*0.35, right_1.height*0.5));
		var right_3=new Button(right_1,10,TAG_RIGHT13,"#WeighingBottle/right_3.png",this.callback,this);
		right_3.setPosition(cc.p(right_1.width*0.5, right_1.height*0.5));
		//拿盖子右手
		var right_11=new Button(this,10,TAG_RIGHT_11,"#WeighingBottle/right_11.png",this.callback,this);
		right_11.setPosition(this.body.width*3.92,this.body.height*0.1);
		right_11.setScale(0.65);
		right_11.setVisible(false);
		var right_12=new Button(right_11,10,TAG_RIGHT_12,"#WeighingBottle/right_12.png",this.callback,this);
		right_12.setPosition(cc.p(right_11.width*0.5, right_11.height*0.5));
		var right_13=new Button(right_11,10,TAG_RIGHT_13,"#WeighingBottle/right_13.png",this.callback,this);
		right_13.setPosition(cc.p(right_11.width*0.5, right_11.height*0.5));
		//拿盖子左手
		var left1=new Button(this,10,TAG_LEFT1,"#WeighingBottle/left1.png",this.callback,this);
		left1.setPosition(this.body.width*4,-this.body.height*0.15);
		left1.setScale(0.65);
		left1.setVisible(false);
		var left2=new Button(left1,10,TAG_LEFT2,"#WeighingBottle/left2.png",this.callback,this);
		left2.setPosition(left1.width*0.5,left1.height*0.5);	
		var left3=new Button(left1,10,TAG_LEFT3,"#WeighingBottle/left3.png",this.callback,this);
		left3.setPosition(left1.width*0.5,left1.height*0.5);
	},
	back:function(){
		var rotate=cc.rotateBy(1,-85);
		var right_1=this.getChildByTag(TAG_RIGHT11);
		var ber2=cc.bezierBy(1,[cc.p(-10,30),cc.p(-35, 65),cc.p(-180,150)]);
		right_1.runAction(cc.sequence(cc.delayTime(0.1),cc.spawn(ber2.reverse(),rotate.reverse())));
	},
	inputInto:function(){
		var func=cc.callFunc(function(){
			gg.flow.next();
		},this);
		var balance=ll.run.getChildByTag(TAG_BALANCE_ALL);
		var num=balance.getChildByTag(TAG_NUM);
		var right=this.body.getChildByTag(TAG_RIGHT_1);
		var ber=cc.bezierBy(1, [cc.p(-20, 50),cc.p(-65, 55),cc.p(-258, 25)]);
		var ber1=cc.bezierBy(1,[cc.p(20, 50),cc.p(80,55),cc.p(450,-50)]);
		var ber2=cc.bezierBy(1,[cc.p(-10,30),cc.p(-35, 65),cc.p(-180,150)]);
		var ber3=cc.bezierBy(1, [cc.p(-20, 30),cc.p(-50, 65),cc.p(-260,110)]);
		var ber4=cc.bezierBy(1, [cc.p(20, -30),cc.p(50,-50),cc.p(175,-80)]);
		var ber5=cc.bezierBy(1, [cc.p(-20,50),cc.p(-200, 55),cc.p(-447, 52)])
		var rotate=cc.rotateBy(1,-85);
		var move=cc.moveBy(1,cc.p(0,10));
		this.body.runAction(cc.sequence(cc.callFunc(function() {
			right.setVisible(true);
		},this),ber,cc.callFunc(function() {
			num.setSpriteFrame("num3.png");
			right.setVisible(false);
		},this),func));
	},
	callback:function(p){
		var func=cc.callFunc(function(){
			gg.flow.next();
		},this);
		var body=this.getChildByTag(TAG_WEIGHING);
		var cup=body.getChildByTag(TAG_CUP);
		var action=gg.flow.flow.action;
		var balance=ll.run.getChildByTag(TAG_BALANCE_ALL);
		var num=balance.getChildByTag(TAG_NUM);
		var right=body.getChildByTag(TAG_RIGHT_1);
		var beaker=ll.run.getChildByTag(TAG_BEAKER_ALL);
		var right_1=this.getChildByTag(TAG_RIGHT11);
		var right_2=right_1.getChildByTag(TAG_RIGHT12);
		var right_11=this.getChildByTag(TAG_RIGHT_11);
		var left1=this.getChildByTag(TAG_LEFT1);
		switch(p.getTag()){
		case TAG_WEIGHING:
			var ber=cc.bezierBy(1, [cc.p(-20, 50),cc.p(-65, 55),cc.p(-258, 25)]);
			var ber1=cc.bezierBy(1,[cc.p(20, 50),cc.p(80,55),cc.p(450,-50)]);
			var ber2=cc.bezierBy(1,[cc.p(-10,30),cc.p(-35, 65),cc.p(-180,150)]);
			var ber3=cc.bezierBy(1, [cc.p(-20, 30),cc.p(-50, 65),cc.p(-260,110)]);
			var ber4=cc.bezierBy(1, [cc.p(20, -30),cc.p(50,-50),cc.p(175,-80)]);
			var ber5=cc.bezierBy(1, [cc.p(-20,50),cc.p(-200, 55),cc.p(-447, 52)])
			var rotate=cc.rotateBy(1,-85);
			var move=cc.moveBy(1,cc.p(0,10));
			if(action==ACTION_DO2){
				p.runAction(cc.sequence(cc.callFunc(function() {
					num.setSpriteFrame("num1.png");
					right.setVisible(true);
				},this),ber1,cc.callFunc(function() {
					right.setVisible(false);
				},this),func));
			}else if(action==ACTION_DO3){
				p.setVisible(false);
				right_1.setVisible(true);
				left1.setVisible(true);
				left1.runAction(cc.sequence(cc.spawn(cc.sequence(ber3,cc.delayTime(0.1)),cc.callFunc(function() {
					right_1.runAction(cc.sequence(cc.delayTime(0.1),cc.spawn(ber2,rotate),cc.callFunc(function() {
						right_2.setSpriteFrame("WeighingBottle/right_21.png");
					},this)));
				},this)),cc.delayTime(0.5),cc.callFunc(function() {
					beaker.showPowder();
				},this),cc.sequence(move,move.reverse(),move,move.reverse(),move,move.reverse()),cc.spawn(cc.sequence(ber4,cc.delayTime(1.1)),
					cc.callFunc(function() {
					this.back();
				},this)),cc.callFunc(function() {
					body.setVisible(true);
					body.setSpriteFrame("WeighingBottle/c3.png");
					cup.setPosition(cc.p(this.body.width*0.5, this.body.height*0.95));
					cup.setRotation(0);
					right_1.setVisible(false);
					left1.setVisible(false);
				},this),func));
			}else if(action==ACTION_DO4){
				p.runAction(cc.sequence(cc.callFunc(function() {
					right.setVisible(true);
				},this),ber5,cc.callFunc(function() {
					num.setSpriteFrame("num4.png");
					right.setVisible(false);
				},this),func));
			}else if(action==ACTION_DO5){
				p.runAction(cc.sequence(cc.callFunc(function() {
					right.setVisible(true);
				},this),ber5.reverse(),cc.callFunc(function() {
					num.setSpriteFrame("num1.png");
					right.setVisible(false);
					p.setVisible(false);
				},this),func));
			}
			break;
		case TAG_CUP:
			p.setVisible(false);
			right_11.setVisible(true);
			var ber=cc.bezierBy(1, [cc.p(15, 30),cc.p(45, 35),cc.p(80, -80)]);
			var rotate=cc.rotateBy(1,180);
			right_11.runAction(cc.sequence(cc.spawn(cc.spawn(ber,rotate),cc.sequence(cc.delayTime(0.8),cc.callFunc(function(){
				p.setVisible(true);
				p.setPosition(cc.p(this.body.width*0.5+80, this.body.height*0.95-80));
				p.setRotation(180);
			},this),cc.callFunc(function() {
				right_11.setVisible(false);
			},this))),func));
			break;
		default:
			break;
		}
	}
});